package com.chuangjiangx.member.coupon.ddd.domain.model;

/**
 * 会员卡封面选项枚举
 *
 * @author wp
 * @create 2018-08-28 14:56
 **/
public enum WxStatusEnum {

    UN_COMMIT("未提交审核",0),
    AUDITING("审核中",1),
    AUDIT_FAIL("审核失败",2),
    AUDIT_SUCCESS("审核成功",3),
    DELETED("卡券被商户删除",4),
    PUTED("在工作平台投放过卡券",5)
    ;

    public String name;
    public Integer code;

    WxStatusEnum(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public static WxStatusEnum fromCode(Integer code){
        for(WxStatusEnum wxStatusEnum: WxStatusEnum.values()){
            if(code.equals(wxStatusEnum.code)){
                return wxStatusEnum;
            }
        }
        throw new IllegalStateException("不存在 的微信审核状态:  "+code);
    }

    public static WxStatusEnum fromWxStatus(String wxStatus){
        switch (wxStatus){
            case "CARD_STATUS_NOT_VERIFY":
                return AUDITING;
            case "CARD_STATUS_VERIFY_FAIL":
                return AUDIT_FAIL;
            case "CARD_STATUS_VERIFY_OK":
                return AUDIT_SUCCESS;
            case "CARD_STATUS_DELETE":
                return DELETED;
            case "CARD_STATUS_DISPATCH":
                return PUTED;
            default:
                throw new IllegalStateException("未定义的微信状态值");
        }
    }
}
